package com.ss.android.b;

import com.bytedance.common.utility.NetworkType;
import com.ss.android.b.b.BaseVideoManager;
import com.ss.android.common.util.NetworkUtils;
import com.ss.android.image.BaseImageManager;
import com.ss.android.image.model.ImageInfo;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;

final class e extends AdManager.g {
    private final AdManager e;
    private final List a;
    private final BaseVideoManager b;
    private final BaseImageManager c;
    private final List d;

    e(AdManager arg2, List arg3, BaseVideoManager arg4, BaseImageManager arg5, List arg6) {
        super((byte) 0);
        this.e = arg2;
        this.a = arg3;
        this.b = arg4;
        this.c = arg5;
        this.d = arg6;

    }

    public final void a() {
        int v0_1;
        Iterator v9;
        boolean v8;
        int v1_1;
        Object v0;
        String v6 = null;
        int v3 = 0;
        if(this.e.i == null) {
            this.e.i = new HashSet();
        }

        Iterator v7 = this.a.iterator();
        int v2 = 0;
        while(true) {
        label_13:
            if(v7.hasNext()) {
                v0 = v7.next();
                NetworkType v1 = NetworkUtils.getNetworkType(this.e.mContext);
                int v4 = v1 == NetworkType.WIFI ? 1 : 0;
                switch(f.a[v1.ordinal()]) {
                    case 1: {
                        v1_1 = 16;
                        break;
                    }
                    case 2: {
                        v1_1 = 8;
                        break;
                    }
                    case 3: {
                        v1_1 = 4;
                        break;
                    }
                    case 4: {
                        v1_1 = 1;
                        break;
                    }
                    default: {
                        v1_1 = 0;
                        break;
                    }
                }

                v1_1 = (v1_1 & ((AdManager.b)v0).k) > 0 ? 1 : 0;
                if(v1_1 == 0) {
                    AdManager.a(((AdManager.b)v0).q, ((AdManager.b)v0).r, this.b);
                    continue;
                }

                if(((AdManager.b)v0).q != 0) {
                    if(v4 != 0) {
                        if(this.e.a(this.b, this.c, ((AdManager.b)v0))) {
                            this.e.i.add(Long.valueOf(((AdManager.b)v0).id));
                            v0_1 = v2 + 1;
                        } else {
                            v0_1 = v2;
                        }

                        v2 = v0_1;
                        continue;
                    }
                }else {
                    v8 = this.e.a(this.c, ((AdManager.b) v0).a);
                    if (v8) {
                        this.e.i.add(Long.valueOf(((AdManager.b) v0).id));
                    }

                    if (v4 != 0 && !((AdManager.b) v0).o.isEmpty()) {
                        v9 = ((AdManager.b) v0).o.iterator();
                        while (v9.hasNext()) {
                            Object v1_2 = v9.next();
                            if (v1_2 == null) {
                                continue;
                            }

                            if (!((AdManager.b) v1_2).isValid()) {
                                continue;
                            }

                            if (!this.e.a(this.c, ((AdManager.b) v1_2).a)) {
                                continue;
                            }

                            this.e.i.add(Long.valueOf(((AdManager.b) v0).id));
                        }
                    }
                }
            }
            break;
        }

        Iterator v2_1 = this.d.iterator();
        do {
            if(!v2_1.hasNext()) {
                break;
            }
            v0 = v2_1.next();
            boolean v4_1 = NetworkUtils.isWifi(this.e.mContext);
            ImageInfo v1_3 = !android.support.design.a.isTextEmpty(((AdManager.e)v0).url) ? new ImageInfo(((AdManager.e)v0).url, v6) : ((ImageInfo)null);
            if(this.e.a(this.c, v1_3)) {
                this.e.i.add(Long.valueOf(((long)((AdManager.e)v0).ruleId)));
                ++v3;
            }

            if(v4_1) {
               continue;
            }
        } while(v3 <= 0);

        this.e.b();
    }
}

